package com.liang.pcc.service.impl;

import cn.dev33.satoken.stp.StpUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liang.pcc.domain.AuthUser;
import com.liang.pcc.dto.resp.VoltageDeviationCheck;
import com.liang.pcc.mapper.VoltageDeviationCheckMapper;
import com.liang.pcc.service.AuthUserService;
import com.liang.pcc.service.VoltageDeviationCheckService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* 电压偏差校核表Service实现
*/
@Service
@RequiredArgsConstructor
public class VoltageDeviationCheckServiceImpl extends ServiceImpl<VoltageDeviationCheckMapper, VoltageDeviationCheck>
    implements VoltageDeviationCheckService{

    private final AuthUserService authUserService;

    @Override
    public List<VoltageDeviationCheck> getVoltageDeviationByFile(Long fileId) {
        Long userId = authUserService.lambdaQuery()
                .eq(AuthUser::getAccount, StpUtil.getLoginId().toString())
                .one()
                .getId();
        return lambdaQuery()
                .eq(fileId != null, VoltageDeviationCheck::getFileId, fileId)
                .eq(VoltageDeviationCheck::getUserId, userId)
                .list();
    }
}




